#include <ESP8266WiFi.h>

WiFiClient client;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

  Serial.begin(115200);
  Serial.printf("\n\n");

  WiFi.begin("zxc-pc-ap","00000000");
  while(WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.printf(".");
  }
  Serial.printf("\n");
  Serial.printf("Connected!IP:");
  Serial.println(WiFi.localIP());
}

void loop() {
  while(WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.printf(".");
  }

  if(client.connect("192.168.1.216",50000))
  {
    Serial.printf("Connected tcp server!\n");
    digitalWrite(LED_BUILTIN, LOW);
    while(client.connected())
    {
      while(client.available())
      {
        Serial.printf("%c",client.read());
        char c = client.read();
        Serial.print(c);
      }
    }
  }
  Serial.printf("Disconnected tcp server!\n");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(100);
}
